import Vue from 'vue'
import Router from 'vue-router'
import Index from '@/views/common/Index'
import Home from '@/views/Home'

const _import = require('./_import_' + process.env.NODE_ENV)

Vue.use(Router)

let routes = [
  {path: '/login', component: _import('Login')},
  {path: '/404', component: _import('error/404')},
  {
    path: '/',
    component: Home,
    name: '首页',
    children: [{path: 'dashboard', component: Home}]
  },
  {
    path: '/basic',
    name: '基础设置',
    component: Home,
    children: [
      {
        path: 'account',
        name: '帐户管理',
        component: _import('basic/Account')
      },
      {
        path: 'role',
        name: '角色管理',
        component: _import('basic/Role')
      },
      {
        path: 'changePwd',
        name: '修改密码',
        component: _import('basic/ChangePwd')
      },
      {
        path: 'info',
        name: '档案管理',
        component: Index,
        children: [
          {path: 'client', component: _import('basic/info/Client'), name: '客户'},
          {
            path: 'inside',
            name: '内部档案管理',
            component: Index,
            children: [
              {path: 'staff', component: _import('basic/info/inside/Staff'), name: '员工'},
              {path: 'office', component: _import('basic/info/inside/Office'), name: '办事处'}
            ]
          },
          {path: 'outsourcer', component: _import('basic/info/Outsourcer'), name: '外包商'},
          {path: 'factory', component: _import('basic/info/Factory'), name: '工厂'},
          {path: 'product', component: _import('basic/info/Product'), name: '产品'},
          {path: 'materials', component: _import('basic/info/Material'), name: '物料'},
          {path: 'fault', component: _import('basic/info/Fault'), name: '故障'},
          {path: 'outsourcerPoint', component: _import('basic/info/OutsourcerPoint'), name: '外包点'},
          {path: 'outsourcerPointRepairer', component: _import('basic/info/OutsourcerPointRepairer'), name: '外包点维修人员'}
        ]
      }
    ]
  },
  {
    path: '/repairs',
    name: '维修管理',
    component: Home,
    children: [
      {
        path: 'point',
        name: '网点维修',
        component: Index,
        children: [
          {path: 'accept', component: _import('repair/point/Accepts'), name: '受理'},
          {path: 'repair', component: _import('repair/point/Repair'), name: '(网点)维修'},
          {path: 'return', component: _import('repair/point/Return'), name: '返还客户'},
          {path: 'receive', component: _import('repair/point/Receive'), name: '工厂返机'},
          {path: 'logistics', component: _import('repair/point/Logistics'), name: '网点物流信息'},
          {path: 'overview', component: _import('repair/point/Overview'), name: '批次信息一览'}
        ]
      },
      {
        path: 'logistics',
        name: '物流信息',
        component: _import('repair/Logistics')
      },
      {
        path: 'factory',
        component: Index,
        name: '工厂维修',
        children: [
          {path: 'accept', component: _import('repair/factory/Accept'), name: '收机确认'},
          {path: 'repairs', component: _import('repair/factory/Repairs'), name: '工厂维修工单一览'},
          {path: 'batchRepair', component: _import('repair/factory/BatchRepair'), name: '(工厂)批量维修'},
          {path: 'repair', component: _import('repair/factory/Repair'), name: '(工厂)维修'},
          {path: 'return', component: _import('repair/factory/Return'), name: '返还网点'},
          {path: 'scrap', component: _import('repair/factory/Scrap'), name: '报废列表'},
          {path: 'list', component: _import('repair/factory/List'), name: '工厂设备一览'},
          {path: 'overview', component: _import('repair/factory/Overview'), name: '工厂批次详情'}

        ]
      }
    ]
  },
  {
    path: '/standby',
    component: Home,
    name: '备品管理',
    children: [
      {path: 'apply', component: _import('standby/Apply'), name: '备机申请'},
      {path: 'check', component: _import('standby/Check'), name: '备机审核'},
      {path: 'grants', component: _import('standby/Grants'), name: '备机发放'},
      {path: 'grant', component: _import('standby/Grant'), name: '备机发放物流'},
      {path: 'receive', component: _import('standby/Receive'), name: '备机收机'}
    ]
  },
  {
    path: '/allot',
    component: Home,
    name: '调拨管理',
    children: [
      {path: 'apply', component: _import('allot/Apply'), name: '调拨申请'},
      {path: 'audit', component: _import('allot/Audit'), name: '调拨审核'}
    ]
  },
  {
    path: '/stock',
    component: Home,
    name: '库存管理',
    children: [
      {path: 'list', component: _import('stock/List'), name: '库存一览表'},
      {path: 'specialOperation', component: _import('stock/SpecialOperation'), name: '特殊操作'},
      {
        path: 'good',
        component: Index,
        name: '良品库',
        children: [
          {path: 'list', component: _import('stock/good/List'), name: '良品库存状态'},
          {path: 'outstock', component: _import('stock/good/Outstock'), name: '良品库出库一览'},
          {path: 'instock', component: _import('stock/good/Instock'), name: '良品库入库一览'},
          {path: 'allocate', component: _import('stock/good/Allocate'), name: '调拨'},
          {path: 'receive', component: _import('stock/good/Receive'), name: '调拨收机'},
          {path: 'repair/factory/detail', component: _import('stock/good/RepairFactoryDetail'), name: '返厂维修详情'},
          {path: 'repair/point/detail', component: _import('stock/good/RepairPointDetail'), name: '网点维修详情'}
        ]
      },
      {
        path: 'bad',
        component: Index,
        name: '不良品库',
        children: [
          {path: 'list', component: _import('stock/bad/List'), name: '不良品库存状态'},
          {path: 'factory', component: _import('stock/bad/FactoryRepair'), name: '返厂维修'},
          {path: 'outstock', component: _import('stock/bad/Outstock'), name: '不良品库出库一览'},
          {path: 'instock', component: _import('stock/bad/Instock'), name: '不良品库入库一览'}
        ]
      },
      {path: 'scrappage', component: _import('stock/scrap/Scrap'), name: '报废库'},
      {path: 'logistic', component: _import('stock/Logistics'), name: '设备返还物流'}
    ]
  },
  {
    path: '/search',
    component: Home,
    name: '查询管理',
    children: [
      {
        path: 'standby',
        component: Index,
        name: '备机查询',
        children: [
          {path: 'apply', component: _import('search/standby/Apply'), name: '备机申请查询'},
          {path: 'allocate', component: _import('search/standby/Allocate'), name: '备机调拨查询'},
          {path: 'scrappage', component: _import('search/standby/Scrappage'), name: '备机报废查询'},
          {path: 'stock', component: _import('search/standby/Stock'), name: '备机库存查询'}
        ]
      },
      {path: 'repairRecode', component: _import('search/RepairRecode'), name: '维修记录查询'}

    ]
  },
  {
    path: '/statistic',
    name: '统计管理',
    component: Home,
    children: [
      {path: 'pointRepair', component: _import('statistic/PointRepair'), name: '送修统计'},
      {path: 'timeRepair', component: _import('statistic/TimeRepair'), name: '一返三返统计'},
      {path: 'factoryRepair', component: _import('statistic/FactoryRepair'), name: '返厂维修统计'},
      {path: 'spare', component: _import('statistic/Spare'), name: '备机统计'}
    ]
  },
  {
    path: '/approve',
    component: Home,
    name: '审批管理 ',
    children: [
      {path: 'spare', component: _import('approve/Spare'), name: '备机申请审批'},
      {path: 'allot', component: _import('approve/Allot'), name: '调拨审批'},
      {path: 'scrap', component: _import('approve/Scrap'), name: '报废审批'}
    ]
  },
  {
    path: '/config',
    component: Home,
    children: [
      {path: 'auditConfig', component: _import('config/AuditConfig'), name: '审核设置'}
    ]
  },
  {
    path: '/warranty',
    component: Home,
    children: [
      {path: 'contract', component: _import('warranty/Contract'), name: '合同'},
      {path: 'order', component: _import('warranty/Order'), name: '生产订单'},
      {path: 'setting', component: _import('warranty/WarrantySet'), name: '质保设置'}
    ]
  },
  {
    path: '*',
    hidden: true,
    redirect: {path: '/404'}
  }
]
export default new Router({
  routes
})
